package com.cskaoyan.demo4.servlet;

import com.cskaoyan.demo4.service.AdminService;
import com.cskaoyan.demo4.service.AdminServiceImpl;
import com.cskaoyan.demo4.service.GoodsService;
import com.cskaoyan.demo4.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description：
 * @Author：BLUEBLANK
 * @Date：2024/4/18 20:51
 */

@WebServlet("/admin/admin/*")
public class AdminServlet extends HttpServlet{
    ApplicationContext applicationContext;
    AdminService adminService;
    UserService userService;
    GoodsService goodsService;

    @Override
    public void init() throws ServletException {
        applicationContext = (ApplicationContext) getServletContext().getAttribute("ApplicationContext");
        adminService = (AdminService) applicationContext.getBean("adminService");
        userService = (UserService) applicationContext.getBean("userService");
        goodsService = (GoodsService) applicationContext.getBean("goodsService");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("adminServlet get");
        resp.getWriter().write("adminServlet get");
    }
}
